/*
 *          		  MidiMaker 
 *       		   (Working title)
 *  		Joe Mirizio & Earl Bellinger
 * 
 *	GNU General Public License version 3.0 (GPLv3)
 */
package midimaker;

import javax.sound.midi.Track;

public class Guitar extends InstrumentTrack {

    public Guitar(Track track, int channel) {
        super(track, channel);
        setOctave(5);
        changeProgram(0, 0);
    }

    public Guitar(Track track, int channel, int program) {
        this(track, channel);
        changeProgram(program, 0);
    }

    /*    public int[][] generateNotes(int[] harmony) {
    int[][] a = {{harmony[0], 0, 4}, {harmony[0]+2, 0, 4}, {harmony[0]+4, 0, 4},
    {harmony[1], 4, 4}, {harmony[1]+2, 4, 4}, //{harmony[1]+4, 4, 4},
                         {harmony[2], 8, 4}, {harmony[2]+2, 8, 4}, {harmony[2]+4, 8, 4},
                         {harmony[3], 12, 4}, {harmony[3]+2, 12, 4}, {harmony[3]+4, 12, 4},
                         {harmony[4], 16, 4}, {harmony[4]+2, 16, 4}, {harmony[4]-5, 16, 4},
                         {harmony[5], 20, 4}, {harmony[5]+2, 20, 4}, {harmony[5]-5, 20, 4},
                         {harmony[6], 24, 4}, {harmony[6]+2, 24, 4}, {harmony[6]+4, 24, 4},
    {harmony[7], 28, 4}, {harmony[7]+2, 28, 4}, {harmony[7]+4, 28, 4}};
    return a;
    }*/
    public int[][] generateNotes(int[] harmony) {
        int[][] a = new int[3 * harmony.length][];
        int counter = 0;
        for (int i = 0; i < a.length - 2; i = i + 3) {
            a[i] = new int[]{harmony[counter], counter * 4, 4};
            if (harmony[counter] > 4) {
                a[i + 1] = new int[]{harmony[counter] - 5, counter * 4, 4, 1};
                a[i + 2] = new int[]{harmony[counter] - 3, counter * 4, 4, 1};
            } else if (harmony[counter] > 2) {
                a[i + 1] = new int[]{harmony[counter] + 2, counter * 4, 4};
                a[i + 2] = new int[]{harmony[counter] - 3, counter * 4, 4, 1};
            } else {
                a[i + 1] = new int[]{harmony[counter] + 2, counter * 4, 4};
                a[i + 2] = new int[]{harmony[counter] + 4, counter * 4, 4};
            }
            if (i > 0) {
                if (a[i - 2] == a[i + 1] && harmony[i - 1] != harmony[i])
                    if (harmony[counter] > 4)
                        a[i + 1] = new int[]{harmony[counter] - 5, counter * 4, 4, -1};
                    else
                        a[i + 1] = new int[]{harmony[counter] + 2, counter * 4, 4, -1};
                if (a[i - 1] == a[i + 2] && harmony[i - 1] != harmony[i])
                    if (harmony[counter] > 4)
                        a[i + 1] = new int[]{harmony[counter] - 3, counter * 4, 4, -1};
                    else
                        a[i + 1] = new int[]{harmony[counter] + 4, counter * 4, 4, -1};
            }
            counter++;
        }
        return a;
    }
}
